package com.app.repository.impl;

import com.app.model.main.RewardArticle;
import com.app.repository.interfaces.RewardArticleMapper;
import com.app.support.dao.MybatisDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.HashMap;
import java.util.Map;

/**
 * @author triplel
 * @create 2018-05-01 22:13
 */
@Repository
public class RewardArticleMapperImpl implements RewardArticleMapper {

    final String namespace = "com.app.dao.main.RewardArticleMapper";

    @Autowired
    private MybatisDao mybatisDao;

    @Override
    public int deleteByPrimaryKey(Long id) {
        return mybatisDao.delete(namespace,".deleteByPrimaryKey",id);
    }

    @Override
    public int insert(RewardArticle record) {
        return mybatisDao.insert(namespace,".insert",record);
    }

    @Override
    public int insertSelective(RewardArticle record) {
        return mybatisDao.insert(namespace,".insertSelective",record);
    }

    @Override
    public RewardArticle selectByPrimaryKey(Long id) {
        return mybatisDao.get(namespace,".selectByPrimaryKey",id);
    }

    @Override
    public int updateByPrimaryKeySelective(RewardArticle record) {
        return mybatisDao.update(namespace,".updateByPrimaryKeySelective",record);
    }

    @Override
    public int updateByPrimaryKey(RewardArticle record) {
        return mybatisDao.update(namespace,".updateByPrimaryKey",record);
    }

    @Override
    public int updateStatus(Long articleId, byte status) {
        Map<String,Object> map = new HashMap<>();
        map.put("articleId",articleId);
        map.put("status",status);
        return mybatisDao.update(namespace,".updateStatus",map);
    }

    @Override
    public Byte getStatus(Long articleId) {
        return mybatisDao.get(namespace,".getStatus",articleId);
    }

    @Override
    public RewardArticle getByArticleId(Long articleId) {
        return mybatisDao.get(namespace,".getByArticleId",articleId);
    }
}
